
import SparkMD5 from "spark-md5";

async function getFileMd5 (file) {
    var res = await new Promise((resolve, reject) => {
        var fileReader = new FileReader();
        var spark = new SparkMD5.ArrayBuffer();
        // 获取文件二进制数据
        fileReader.readAsArrayBuffer(file);
        fileReader.onload = function (e) {
            spark.append(e.target.result);
            var md5 = spark.end();
            resolve(md5)
        };
    })
    return res
}

export { getFileMd5 }